package com.lianzhihui.romeex.ui.me;

import android.Manifest;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.lianzhihui.romeex.MyApplication;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.adapter.InvitationAdapter;
import com.lianzhihui.romeex.ui.base.BaseActivity;
import com.lianzhihui.romeex.ui.me.dialog.ShareDialog;
import com.lianzhihui.romeex.utils.ImagesUtil;
import com.lianzhihui.romeex.utils.StatusBarUtil;
import com.lianzhihui.romeex.widget.ZFEmptyRecyclerView;

import java.util.ArrayList;

import butterknife.BindView;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.ui.me
 * @ClassName: ThemTeamActivity
 * @Description: java类作用描述
 * @Author: zhanghong
 * @CreateDate: 2020/12/10 16:42
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/12/10 16:42
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class ThemTeamActivity extends BaseActivity  {
    @BindView(R.id.include_top_iv_back)
    ImageView includeTopIvBack;
    @BindView(R.id.include_top_lin_background)
    LinearLayout includeTopLinBackground;
    @BindView(R.id.include_top_lin_newback)
    LinearLayout includeTopLinNewback;
    @BindView(R.id.state_bar)
    View stateBar;

    View saveView;
    private static final int REQUEST_CODE_QRCODE_PERMISSIONS = 1;
    @BindView(R.id.myRecyclerView)
    ZFEmptyRecyclerView myRecyclerView;
    private ShareDialog shareDialog;
    private String inviteCode;
    private InvitationAdapter invitationAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_invitation_layout;
    }

    @Override
    protected void initView() {
        myRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        invitationAdapter = new InvitationAdapter(new ArrayList<>());
        myRecyclerView.setAdapter(invitationAdapter);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, stateBar.getHeight());
        layoutParams.topMargin = StatusBarUtil.getStatusBarHeight(MyApplication.mContext);
        stateBar.setLayoutParams(layoutParams);
        includeTopIvBack.setImageResource(R.drawable.icon_return_w);
        includeTopLinBackground.setBackgroundColor(getResources().getColor(R.color.transparent));
        StatusBarUtil.setTransparentForImageView(this, null);
    }

    @Override
    public boolean setFitSystemWindowFlag() {
        return false;
    }

    @Override
    protected void initData() {
//        Bundle extras = getIntent().getExtras();
////        InvitationPresnterImp invitationPresnterImp = new InvitationPresnterImp(this, this);
//        if (extras != null) {
//            inviteCode = extras.getString(AppConstants.INTENT_INVITATION_CODE, "");
//            if (!inviteCode.isEmpty()) {
////                invCode.setText(inviteCode);
////                ImagesUtil.createQrCodeImg(QRUtils.type4 + inviteCode, qrImage, 500);
//            }
//        } else {
//            invitationPresnterImp.requestHomeInfo();
//        }
//        invitationPresnterImp.requestBindInfo();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }



    @AfterPermissionGranted(REQUEST_CODE_QRCODE_PERMISSIONS)
    private void requestCodeQRCodePermissions(View v) {
        String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
        if (!EasyPermissions.hasPermissions(this, perms)) {
            EasyPermissions.requestPermissions(this, getResources().getString(R.string.text_permissions), REQUEST_CODE_QRCODE_PERMISSIONS, perms);
        } else {
            dismissLoading();
            ImagesUtil.saveQrCode(this, v);
//            toast(getString(R.string.text_string_save_success));
            shareDialog.dismiss();
        }
    }



}
